package xiecheng;

import java.util.*;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        second();
    }

    public static void first() {
        Long num = sc.nextLong();
        String str = Long.toBinaryString(num);
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '1') {
                count++;
            }
        }
        System.out.println(count);
    }

    public static void second() {
        int n = sc.nextInt();
        long num = sc.nextLong();

        for (int i = 0; i < n; i++) {
            long first = sc.nextLong();
            long second = sc.nextLong();
            long third = sc.nextLong();
            if (second < num && num < third) {
                System.out.println(first);
            }
        }
    }

    static class LRUCache<K, V> {

        private int currentCacheSize;
        private int CacheCapcity;
        private HashMap<K, CacheNode> caches;
        private CacheNode first;
        private CacheNode last;

        public LRUCache(int size) {
            currentCacheSize = 0;
            this.CacheCapcity = size;
            caches = new HashMap<K, CacheNode>(size);
        }

        public void put(K k, V v) {
            CacheNode node = caches.get(k);
            if (node == null) {
                if (caches.size() >= CacheCapcity) {
                    caches.remove(last.key);
                    removeLast();
                }
                node = new CacheNode();
                node.key = k;
                moveToFirst(node);
            }
            node.value = v;

            caches.put(k, node);
        }

        public Object get(K k) {
            CacheNode node = caches.get(k);
            if (node == null) {
                return -1;
            }
            moveToFirst(node);
            return node.value;
        }

        private void moveToFirst(CacheNode node) {
            if (first == node) {
                return;
            }
            if (node.next != null) {
                node.next.pre = node.pre;
            }
            if (node.pre != null) {
                node.pre.next = node.next;
            }
            if (node == last) {
                last = last.pre;
            }
            if (first == null || last == null) {
                first = last = node;
                return;
            }

            node.next = first;
            first.pre = node;
            first = node;
            first.pre = null;

        }

        private void removeLast() {
            if (last != null) {
                last = last.pre;
                if (last == null) {
                    first = null;
                } else {
                    last.next = null;
                }
            }
        }

        @Override
        public String toString() {
            StringBuilder sb = new StringBuilder();
            CacheNode node = first;
            while (node != null) {
                sb.append(String.format("%s:%s ", node.key, node.value));
                node = node.next;
            }

            return sb.toString();
        }

        class CacheNode {
            CacheNode pre;
            CacheNode next;
            Object key;
            Object value;

            public CacheNode() {

            }
        }
    }
    public static void third(){
        int cap=Integer.parseInt(sc.nextLine());

        LRUCache<Integer, Integer> map = new LRUCache<>(cap);
        while (sc.hasNext()){
            String str=sc.nextLine();
            String[] strings=str.split(" ");
            if(str.charAt(0)=='p'){
                map.put(Integer.parseInt(strings[1]),Integer.parseInt(strings[2]));
            }else {
                System.out.println(map.get(Integer.parseInt(strings[1])));
            }
        }
    }
    //测试类

    public static void test() {

        //指定缓存最大容量为4
        LRUCache<Integer, Integer> map = new LRUCache<>(2);
        map.put(1, 1);
        map.put(2, 2);
        System.out.println(map.get(1));
        map.put(2, 102);
        map.put(3, 3);
        System.out.println(map.get(1));
        System.out.println(map.get(2));
        System.out.println(map.get(3));

    }
}
